package fhb.mobile.todoapp.datamodell;

import java.util.ArrayList;
import java.util.Date;

public class ToDoItem {
	
	private Date createDate = null;
	private String title = "";
	private String content = "";
	private Date deadline = null;
	private boolean featured = false;
	private boolean completed = false;
	private Date lastChange = null;
	private ArrayList<String> associatedContacts = new ArrayList<String>();
	
	public ToDoItem(String title, String content, Date deadline, boolean featured) {
		setCreateDate(null);
		setTitle(title);
		setContent(content);
		setDeadline(deadline);
		setFeatured(featured);
		setLastChange(null);
	}
	
	public ToDoItem(String title, String content, Date deadline, boolean featured, ArrayList<String> associatedContacts) {
		setCreateDate(null);
		setTitle(title);
		setContent(content);
		setDeadline(deadline);
		setFeatured(featured);
		setLastChange(null);
		setAssociatedContacts(associatedContacts);
	}

	public ToDoItem(Date createDate, String title, String content, Date deadline, boolean featured, boolean completed, Date lastChange, ArrayList<String> associatedContacts) {
		setCreateDate(createDate);
		setTitle(title);
		setContent(content);
		setDeadline(deadline);
		setFeatured(featured);
		setCompleted(completed);
		setLastChange(lastChange);
		setAssociatedContacts(associatedContacts);
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = (createDate != null) ? createDate : new Date(System.currentTimeMillis());
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = (title != null) ? title : "Kein Titel (" + createDate.toLocaleString() + ")";
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = (content != null) ? content : new String();
	}

	public Date getDeadline() {
		return deadline;
	}

	public void setDeadline(Date deadline) {
		this.deadline = (deadline != null) ? deadline : new Date(System.currentTimeMillis());
	}

	public boolean isFeatured() {
		return featured;
	}

	public void setFeatured(boolean featured) {
		this.featured = featured;
	}

	public boolean isCompleted() {
		return completed;
	}

	public void setCompleted(boolean completed) {
		this.completed = completed;
	}

	public Date getLastChange() {
		return lastChange;
	}

	public void setLastChange(Date lastChange) {
		this.lastChange = (lastChange != null) ? lastChange : new Date(System.currentTimeMillis());
	}

	public ArrayList<String> getAssociatedContacts() {
		return associatedContacts;
	}

	public void setAssociatedContacts(ArrayList<String> associatedContacts) {
		this.associatedContacts = (associatedContacts != null) ? associatedContacts : new ArrayList<String>();
	}	
	
	public void addAssociatedContact(String contactID) {
		associatedContacts.add(contactID);
	}
}
